/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Tb_Project_Templatesubject_Relationship",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using MYData.System.IServices;
using Microsoft.AspNetCore.Authorization;
using MYData.Core.Utilities;
using MYData.Entity.DTO.ApiEntity.Input;
using System.Net;
using System.Text;
using System.Collections.Generic;
using MYData.Entity.DomainModels;
using MYData.Entity.DTO.ApiEntity.OutPut;
using NuGet.Packaging;

namespace MYData.System.Controllers
{
    public partial class Tb_Project_Templatesubject_RelationshipController
    {
        private readonly ITb_Project_Templatesubject_RelationshipService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Tb_Project_Templatesubject_RelationshipController(
            ITb_Project_Templatesubject_RelationshipService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        /// <summary>
        /// 通过经费模板Id在关系表中获取曹经费模板的详细信息
        /// </summary>
        /// <param name="fundtemplateId"></param>
        /// <returns></returns>
        [HttpPost,HttpGet,Route("Get_Fundtemplate_ItemList")]
        public async Task<IActionResult> Get_Fundtemplate_ItemList(string fundtemplateId)
        {
            return Json(await Service.Get_Fundtemplate_ItemList(fundtemplateId));
        }
        /// <summary>
        /// 获取所有预算科目信息（启用的）分直接间接
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetFundingItemList")]
        public async Task<IActionResult> GetFundingItemList()
        {
            return Json(await _service.GetFundingItemList());
        }
        /// <summary>
        /// 获取所有预算科目信息（启用的）
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetFundingItemListAll")]
        public async Task<IActionResult> GetFundingItemListAll()
        {
            return Json(await _service.GetFundingItemListAll());
        }

        /// <summary>
        /// 添加模板科目关系表
        /// </summary>
        /// <param name="TemplateSubjectItemInput_Dto">模板科目关系表dto</param>
        /// <returns></returns>
        [HttpPost,Route("InsertTemplateSubjectItemsAsync")]
        public async Task<IActionResult> InsertTemplateSubjectItemsAsync(TemplateSubjectItemInput_Dto inputDto)
        {
            return Json(await _service.InsertTemplateSubjectItemsAsync(inputDto));
        }

        /// <summary>
        ///  修改模板科目关系表
        /// </summary>
        /// <param name="TemplateSubjectItemInput_Dto">模板科目关系表dto集合</param>
        /// <returns></returns>
        [HttpPost, Route("UpdateTemplateSubjectItemsAsync"), AllowAnonymous]
        public async Task<IActionResult> UpdateTemplateSubjectItemsAsync([FromBody]List<UpdatefundingItem_dto> inputDto)
        {
            return Json(await _service.UpdateTemplateSubjectItemsAsync(inputDto));
        }
        /// <summary>
        /// 根据模板id获取经费科目Id字符串
        /// MJZ 2023/03/31 15:18
        /// </summary>
        /// <param name="fundtemplateId">模板ID</param>
        /// <returns></returns>
        [HttpGet, Route("GetBudgeSubject")]
        public async Task<IActionResult> GetBudgeSubject(string fundtemplateId)
        {
            return Json(await _service.GetBudgeSubject(fundtemplateId));
        }

        /// <summary>
        /// 根据模板Id获取经费科目（子集不在父级身后，选中的子集在父级身后）
        ///  MJZ 2023/4/2 10:18
        /// </summary>
        /// <param name="fundtemplateId">模板ID</param>
        /// <returns></returns>
        [HttpGet, Route("GetBudgeSubjectTemp")]
        public async Task<IActionResult> GetBudgeSubjectTemp(string fundtemplateId)
        {
            return Json(await _service.GetBudgeSubjectTemp(fundtemplateId));
        }
    }
}
